package com.lcj.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;

public class UserInvacationHander implements InvocationHandler {
    private Object target;

    public UserInvacationHander(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("在"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"时间，访问了"+target+" 中" +method.getName()+"方法");
        Object invoke = method.invoke(target, args);
        System.out.println("在"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"时间，请求结束了"+target+" 中"+method.getName()+"方法"+"返回结果为"+invoke);
        return invoke;
    }
}
